<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use Mine\MineModel;

/**
 * @property int $id 
 * @property int $uid 
 * @property int $main_uid 
 * @property int $scheme_id 方案ID
 * @property int $robot_id 机器人ID
 * @property int $status 状态：0=禁用 1=启用
 * @property int $type 类型
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at 
 * @property-read null|ChRobot $robot 
 */
class ChOpSchemeRobot extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_op_scheme_robot';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'uid', 'main_uid', 'scheme_id', 'robot_id', 'status', 'type', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'uid' => 'integer', 'main_uid' => 'integer', 'scheme_id' => 'integer', 'robot_id' => 'integer', 'status' => 'integer', 'type' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function robot()
    {
        return $this->hasOne(ChRobot::class, 'id', 'robot_id');
    }

    public function scheme()
    {
        return $this->hasOne(ChOpScheme::class, 'id', 'scheme_id');
    }

    public function config(): \Hyperf\Database\Model\Relations\HasOne
    {
        return $this->hasOne(ChSendConfig::class,'robot_id','robot_id');
    }
}
